<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/28 0028
 * Time: 下午 4:19
 */
namespace app\api\controller;
use app\admin\model\Goodsclassify as Goodsclassifymodel;
class Goodsclassify extends Baseapi{
    /**
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     *首页点击一级分类以及分类页面点击左侧一级分类获取的二级分类数据
     */
    public function getgoodsclassifylist($id){
        $list=Goodsclassifymodel::getchildlist($id);
        return jsonp($list);
    }
    /**
     * @return \think\response\Jsonp
     * @throws \think\exception\DbException
     * 分类页面左侧一级分类列表
     */
    public function getleftlist(){
        $list=Goodsclassifymodel::all(function ($query){
            $query->field('id,classify_name')
                ->where('father_id',0)
                ->where('status',1)
                ->order('sort', 'asc');
        });
        return jsonp($list);
    }
}
